package ycl.security.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;
import ycl.common.result.Result;
import ycl.common.utils.ServletUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 退出登录成功
 *
 * @author ycl
 * @date 2022-03-10 13:08:54
 */
@Component
@Slf4j
public class AuthLogoutSuccessHandler implements LogoutSuccessHandler {
	@Override
	public void onLogoutSuccess(HttpServletRequest request,
								HttpServletResponse response,
								Authentication authentication)
			throws IOException {
		Result<Object> result = Result.success();
		ServletUtil.writeResponse(response, result);
	}
}
